﻿<%@ WebHandler Language="C#" Class="ZSWorkingProcessInfoLookBoardHanlder" %>

using System;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using System.Web.SessionState;
using System.IO;
using ReportBusiness;

public class ZSWorkingProcessInfoLookBoardHanlder : IHttpHandler
{
    public bool IsReusable { get { return false; } }
    private static ZSWorkingProcessLookBoardBusiness pdb = new ZSWorkingProcessLookBoardBusiness();
    public void ProcessRequest(HttpContext context)
    {
        //年生产任务完成进度
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetYearWorkingProcessInfo")
        {
            DataTable dt = pdb.GetZsYearWorkingProcess();
            var resultJson = JsonConvert.SerializeObject(dt);
            context.Response.ContentType = "text/json";
            context.Response.Write(resultJson);
            context.Response.End();
        }
        //年生产任务完成明细
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetYearFinish")
        {
            Dictionary<string, object> para = new Dictionary<string, object>();
            if (context.Request.Form["queryType"] != null)
            {
                para["queryType"] = context.Request.Form["queryType"].ToString();
            }

            if (context.Request.Form["page"] != null)
            {
                para["page"] = context.Request.Form["page"].ToString();
            }

            if (context.Request.Form["rows"] != null)
            {
                para["rows"] = context.Request.Form["rows"].ToString();
            }

            int pageCount;
            int rowCount;

            DataTable dt = pdb.GetZsYearWorkingFinish(para, out pageCount, out rowCount);

            var json = JsonConvert.SerializeObject(dt);
            context.Response.ContentType = "text/json";

            json = "{\"data\":" + json.ToString()
                    + ",\"count\":" + rowCount
                    + ",\"code\":" + "0"
                    + ",\"msg\":" + "0"
                    + "}";
            context.Response.Write(json.ToString());
            context.Response.End();
        }
        //批产本月进度
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetPiChanData")
        {
            DataTable dt = pdb.GetPiChanData();
            var resultJson = JsonConvert.SerializeObject(dt);
            context.Response.ContentType = "text/json";
            context.Response.Write(resultJson);
            context.Response.End();
        }
        //批产本月进度明细
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetPiChanDetailsData")
        {
            Dictionary<string, object> para = new Dictionary<string, object>();
            if (context.Request.Form["productfamilyname"] != null)
            {
                para["productfamilyname"] = context.Request.Form["productfamilyname"].ToString();
            }
            if (context.Request.Form["queryType"] != null)
            {
                para["queryType"] = context.Request.Form["queryType"].ToString();
            }
            if (context.Request.Form["page"] != null)
            {
                para["page"] = context.Request.Form["page"].ToString();
            }
            if (context.Request.Form["rows"] != null)
            {
                para["rows"] = context.Request.Form["rows"].ToString();
            }

            int pageCount = 0;
            int rowCount = 0;

            DataTable dt = pdb.GetPiChanDetailsData(para, out pageCount, out rowCount);

            var json = JsonConvert.SerializeObject(dt);
            context.Response.ContentType = "text/json";
            //json = "{\"rows\":" + json.ToString() + ",\"total\":" + rowCount + "}";
            json = "{\"data\":" + json.ToString()
                    + ",\"count\":" + rowCount
                    + ",\"code\":" + "0"
                    + ",\"msg\":" + "0"
                    + "}";
            context.Response.Write(json.ToString());
            context.Response.End();
        }
        //修理/备件本月进度
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetXiuliOrBeiJianData")
        {
            DataTable dt = pdb.GetXiuliOrBeiJianData();
            var resultJson = JsonConvert.SerializeObject(dt);
            context.Response.ContentType = "text/json";
            context.Response.Write(resultJson);
            context.Response.End();
        }
        //修理/备件本月进度明细
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetXiuliOrBeiJianDetailsData")
        {
            Dictionary<string, object> para = new Dictionary<string, object>();
            if (context.Request.Form["ordertypename"] != null)
            {
                para["ordertypename"] = context.Request.Form["ordertypename"].ToString();
            }
            if (context.Request.Form["queryType"] != null)
            {
                para["queryType"] = context.Request.Form["queryType"].ToString();
            }
            if (context.Request.Form["page"] != null)
            {
                para["page"] = context.Request.Form["page"].ToString();
            }
            if (context.Request.Form["rows"] != null)
            {
                para["rows"] = context.Request.Form["rows"].ToString();
            }

            int pageCount = 0;
            int rowCount = 0;

            DataTable dt = pdb.GetXiuliOrBeiJianDetailsData(para, out pageCount, out rowCount);

            var json = JsonConvert.SerializeObject(dt);
            context.Response.ContentType = "text/json";
            //json = "{\"rows\":" + json.ToString() + ",\"total\":" + rowCount + "}";
            json = "{\"data\":" + json.ToString()
                    + ",\"count\":" + rowCount
                    + ",\"code\":" + "0"
                    + ",\"msg\":" + "0"
                    + "}";
            context.Response.Write(json.ToString());
            context.Response.End();
        }
        //新机各工序进度
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetXinjiStepInfo")
        {
            Dictionary<string, object> para = new Dictionary<string, object>();
            if (context.Request.Form["currentPage"] != null)
            {
                para["page"] = context.Request.Form["currentPage"].ToString();
            }

            if (context.Request.Form["pageSize"] != null)
            {
                para["rows"] = context.Request.Form["pageSize"].ToString();
            }

            int pageCount = 0;
            int rowCount = 0;

            DataTable dt = pdb.GetXinjiStepInfo(para, out pageCount, out rowCount);

            var json = JsonConvert.SerializeObject(dt);
            context.Response.ContentType = "text/json";
            json = "{\"rows\":" + json.ToString() + ",\"total\":" + rowCount + ",\"pageCount\":" + pageCount + "}";
            context.Response.Write(json.ToString());
            context.Response.End();
        }
        //新机各工序进度--明细
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetXinjiStepDetailsInfo")
        {
            Dictionary<string, object> para = new Dictionary<string, object>();
            if (context.Request.Form["page"] != null)
            {
                para["page"] = context.Request.Form["page"].ToString();
            }

            if (context.Request.Form["rows"] != null)
            {
                para["rows"] = context.Request.Form["rows"].ToString();
            }

            if (context.Request.Form["engineno"] != null)
            {
                para["engineno"] = context.Request.Form["engineno"].ToString();
            }

            int pageCount = 0;
            int rowCount = 0;

            DataTable dt = pdb.GetXinjiStepDetailsInfo(para, out pageCount, out rowCount);

            var json = JsonConvert.SerializeObject(dt);
            context.Response.ContentType = "text/json";
            //json = "{\"rows\":" + json.ToString() + ",\"total\":" + rowCount + ",\"pageCount\":" + pageCount + "}";
            json = "{\"data\":" + json.ToString()
                    + ",\"count\":" + rowCount
                    + ",\"code\":" + "0"
                    + ",\"msg\":" + "0"
                    + "}";
            context.Response.Write(json.ToString());
            context.Response.End();
        }
    }
}